-- 
---@class EstFuncs
local Est = {}

Est.getCanBeDiscardedCards = function(player)
  local arr = {}
  for _, id in ipairs(player:getCardIds("he")) do
    if not player:prohibitDiscard(id) then
      table.insert(arr, id)
    end
  end
  return arr
end

Est.burnCards = function(room, player, cids, skill_name)
  skill_name = skill_name or "burnCards"

  room:sendLog{
    type = "#BurnCardsLog",
    from = player.id,
    card = cids,
  }

  room.logic:trigger("fk.BeforeBurnCards", player, {cards = cids, skillName = skill_name})
  room:moveCardTo(cids, Card.Void, nil, fk.ReasonJustMove, skill_name, nil, true, player.id)
  room.logic:trigger("fk.AfterBurnCards", player, {cards = cids, skillName = skill_name})

  return cids
end

Fk:loadTranslationTable{
  ["#BurnCardsLog"] = "%from 焚烧了 %card"
}

Est.askForChooseCardsAndPlayers = function(room, player, minCardNum, maxCardNum, targets, minTargetNum, maxTargetNum, pattern, prompt, skillName, cancelable, no_indicate, xpand_pile)
  cancelable = (cancelable == nil) and true or cancelable
  no_indicate = no_indicate or false
  pattern = pattern or "."

  local pcards = table.filter(player:getCardIds({ Player.Hand, Player.Equip }), function(id)
    local c = Fk:getCardById(id)
    return c:matchPattern(pattern)
  end)
  if #pcards < minCardNum and not cancelable then return {}, {} end

  local data = {
    targets = targets,
    max_t_num = maxTargetNum,
    min_t_num = minTargetNum,
    max_c_num = maxCardNum,
    min_c_num = minCardNum,
    pattern = pattern,
    skillName = skillName,
    targetTipName = targetTipName,
    expand_pile = expand_pile,
  }
  local _, ret = room:askForUseActiveSkill(player, "ex__choose_skill", prompt or "", cancelable, data, no_indicate)
  if ret then
    return ret.targets, ret.cards
  else
    if cancelable then
      return {}, {}
    else
      return table.random(targets, minTargetNum), table.random(pcards, minCardNum)
    end
  end
end

return Est